package com.two.screen.water.balance.bean.database;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.ToMany;

import java.util.List;

import org.greenrobot.greendao.DaoException;

@Entity
public class CateDB {
    @Id(autoincrement = true)
    public Long   id;//本地id
    public String cateName;//分类名
    public String cateId;//分类id

    public Boolean isSelected = false;//本地使用 :

    //由于存在不同帐号，所拥有的商品的分类不一样。
    public Long   userId;//用户id
    public String userName;//用户名

    public Long sort      = 0L;//排序
    public int  isDeleted = 0;//0 正常 1删除

    //此处的userId是在CateDB中定义的一个变量（请看CateDB.java）
    @ToMany(referencedJoinProperty = "cateId")
    public List<ProductDB> productDBList;


    /**
     * Used to resolve relations
     */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /**
     * Used for active entity operations.
     */
    @Generated(hash = 1722956934)
    private transient CateDBDao  myDao;

    @Generated(hash = 1996577627)
    public CateDB(Long id, String cateName, String cateId, Boolean isSelected, Long userId,
            String userName, Long sort, int isDeleted) {
        this.id = id;
        this.cateName = cateName;
        this.cateId = cateId;
        this.isSelected = isSelected;
        this.userId = userId;
        this.userName = userName;
        this.sort = sort;
        this.isDeleted = isDeleted;
    }

    @Generated(hash = 1640030146)
    public CateDB() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCateName() {
        return this.cateName;
    }

    public void setCateName(String cateName) {
        this.cateName = cateName;
    }

    public String getCateId() {
        return this.cateId;
    }

    public void setCateId(String cateId) {
        this.cateId = cateId;
    }

    public Boolean getIsSelected() {
        return this.isSelected;
    }

    public void setIsSelected(Boolean isSelected) {
        this.isSelected = isSelected;
    }

    public Long getUserId() {
        return this.userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 1921697641)
    public List<ProductDB> getProductDBList() {
        if (productDBList == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ProductDBDao targetDao = daoSession.getProductDBDao();
            List<ProductDB> productDBListNew = targetDao
                    ._queryCateDB_ProductDBList(id);
            synchronized (this) {
                if (productDBList == null) {
                    productDBList = productDBListNew;
                }
            }
        }
        return productDBList;
    }

    /**
     * Resets a to-many relationship, making the next get call to query for a fresh result.
     */
    @Generated(hash = 487991226)
    public synchronized void resetProductDBList() {
        productDBList = null;
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    public int getIsDeleted() {
        return this.isDeleted;
    }

    public void setIsDeleted(int isDeleted) {
        this.isDeleted = isDeleted;
    }

    public Long getSort() {
        return this.sort;
    }

    public void setSort(Long sort) {
        this.sort = sort;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 380741305)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getCateDBDao() : null;
    }
}
